﻿// ----------------------------------------------------------------------------------
// Sample Code from Fernando Machado Píriz's blog: http://fernandomachadopiriz.com
//
// <copyright company="Fernando Machado Píriz" file="ScreensaverModel.cs">
// Copyright (c) Fernando Machado Píriz. Distributed under FSF's GPL v2.</copyright>
// ----------------------------------------------------------------------------------
// This code and information are provided "as is" without warranty of any kind,
// either expressed of implied, including but not limited to the implied warranties
// of merchantability and/or fitness for a particular purpose.
// ----------------------------------------------------------------------------------
namespace Screensaver
{
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Reflection;
    using GivingAPresentation.Commons;
    
    /// <summary>
    /// The model of the <code>ScreensaverView</code> using the Model View View Model pattern.
    /// </summary>
    public class ScreensaverModel : BaseModel
    {
        /// <summary>
        /// The name of the setting exposed in this user control.
        /// </summary>
        private const string TurnOffScreensaverSettingName = "TurnOffScreensaver";

        /// <summary>
        /// Backend field for the <code>Remove</code> property.
        /// </summary>
        private bool hide;

        /// <summary>
        /// Gets or sets a value indicating whether the desktop background should be hided while the user is giving a presentation.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly",
            MessageId = "TurnOff", Justification = "TurnOff is correctly spelled.")]
        public bool TurnOff
        {
            get
            {
                return this.hide;
            }

            set
            {
                this.hide = value;
                this.NotifyPropertyChanged("TurnOff");
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the user is giving a presentation.
        /// </summary>
        public bool Presenting { get; set; }

        /// <summary>
        /// Load model state using the <code>SettingsManager</code>.
        /// </summary>
        internal void Load()
        {
            this.TurnOff = SettingsManager.Instance.GetValue(TurnOffScreensaverSettingName, true);
        }

        /// <summary>
        /// Saves model state using the <code>SettingsManager</code>.
        /// </summary>
        internal void Save()
        {
            SettingsManager.Instance.SetValue(TurnOffScreensaverSettingName, this.TurnOff);
        }
    }
}
